package com.caiyi.financial.nirvana.sms.queue;

import com.caiyi.financial.nirvana.sms.jedis.JedisKey;
import com.caiyi.financial.nirvana.sms.jedis.JedisService;
import com.caiyi.financial.nirvana.sms.task.AlarmMsgSendTask;
import com.caiyi.financial.nirvana.sms.util.ThreadPoolUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;

import java.util.List;

@Component
public class AlarmMessageQueue implements IRedisQueue {

    public Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private Environment env;

    @Override
    public String key() {
        return JedisKey.SMS_QUEUE_ALARM_MSG_SEND;
    }

    public void run(List<String> list) {
        if (list == null || list.isEmpty()) {
            return;
        }
        AlarmMsgSendTask task = new AlarmMsgSendTask(list.get(1), env.getActiveProfiles()[0]);
        ThreadPoolUtil.EXECUTOR_AlARM_MESSAGE.execute(task);
    }

    @Override
    public void interrupt(Exception e) {

    }
}
